home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / AECUR100.ARJ / LINE.C < prev    next >
C/C++ Source or Header  |  1990-03-08  |  1KB  |  71 lines

  1. /*----------------------------------------------------------------------
  2.  * 
  3.  *  line.c
  4.  *
  5.  *  copyright (c) 1987,88,89,90 J. Alan Eldridge
  6.  *
  7.  *  there are 3 functions here
  8.  *
  9.  *  for all functions, n = 0 for single line and 1 for double line
  10.  *
  11.  *  linechar(h_or_v,n)
  12.  *
  13.  *      returns a horizontal (h_or_v==0) or vertical (h_or_v==1) line character
  14.  *
  15.  *  whline(win,n,len) 
  16.  *
  17.  *  wvline(win,n,len)
  18.  *
  19.  *      draws a line on the specified window, starting at the current
  20.  *      cursor position, does not move the cursor, will not overflow
  21.  *      the window
  22.  *
  23.  *----------------------------------------------------------------------
  24.  */
  25.  
  26. #include "curses.h"
  27.  
  28. static UCHAR linechars[][2] = {
  29.     196, 205, 179, 186
  30. };
  31.  
  32. int
  33. linechar(h_or_v, n)
  34. int h_or_v, n;
  35. {
  36.     return linechars[h_or_v][n];
  37. }
  38.  
  39. void
  40. whline(win, n, len)
  41. WINDOW  *win;
  42. int     n, len;
  43. {
  44.     int y, x;
  45.  
  46.     getyx(win, y, x);
  47.     if (len > getmaxc(win) - x + 1)
  48.         len = getmaxc(win) - x + 1;
  49.     while (len-- > 0)
  50.         waddch(win, linechars[0][n]);
  51.     wmove(win, y, x);
  52. }
  53.  
  54. void
  55. wvline(win, n, len)
  56. WINDOW  *win;
  57. int     n, len;
  58. {
  59.     int y1, y2, x;
  60.  
  61.     getyx(win, y1, x);
  62.     if (len > getmaxr(win) - y1 + 1)
  63.         len = getmaxr(win) - y1 + 1;
  64.     y2 = y1;
  65.     while (len-- > 0) {
  66.         waddch(win, linechars[1][n]);
  67.         wmove(win, ++y2, x);
  68.     }
  69.     wmove(win, y1, x);
  70. }
  71.